#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
开放商户 - 进件查询功能使用示例
"""

import os
import sys

# 添加项目根目录到Python路径，确保能够导入jlpay包
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))

from examples.base_example import BaseExample
from jlpay.services.openmerch.register.incoming_query_service import IncomingQueryService
from jlpay.model.openmerch.register.incoming_query import IncomingQueryRequest


class IncomingQueryExample(BaseExample):
    """进件查询示例类"""
    
    def __init__(self):
        """初始化示例类"""
        super().__init__("examples.openmerch.register.incoming_query")
        # 创建进件查询服务实例
        self.incoming_query_service = IncomingQueryService(self.config)
    
    def build_incoming_query_request(self):
        """构建进件查询请求"""
        request = IncomingQueryRequest()
        
        # 设置请求参数
        request.set_apply_id("0ca58d247b7242f0b1bc1a4e357e0abe")
        
        return request
    
    def demo(self):
        """执行进件查询示例"""
        self.logger.info("开始执行进件查询示例")
        
        # 创建进件查询请求
        request = self.build_incoming_query_request()
        
        # 发送请求
        self.send_request_and_handle_response(
            self.incoming_query_service.query_incoming,
            "进件查询",
            request
        )
        
        self.logger.info("进件查询示例执行完毕")


if __name__ == "__main__":
    example = IncomingQueryExample()
    example.logger.info("=" * 50)
    example.logger.info("===== 进件查询示例 开始 =====")
    example.logger.info("=" * 50)
    
    example.demo()
    
    example.logger.info("=" * 50)
    example.logger.info("===== 进件查询示例执行完毕 =====")
    example.logger.info("=" * 50) 